]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Close SHOWING banner when its notification is destroyed
authorSebastian Keller <skeller@gnome.org>
Sat, 25 Dec 2021 23:19:25 +0000 (00:19 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 5 Jan 2022 15:51:14 +0000 (15:51 +0000)
Currently only banners in the SHOWN state are hidden when the underlying
notification is destroyed, but if they are in the SHOWING state, they
remain visible. Because the 'notification' member has already been set
to null when the notification got destroyed, closing the banner by
clicking on the close button, will not do anything and clicking on the
notification itself will result in an error message. For notifications
without a timeout, i.e. critical ones, this will result in an
uncloseable notification.

This can happen if the program creating a critical notification
immediately closes it again, as might happen with power notifications
from gnome-settings-daemon in some situations.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4855
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2079>

js/ui/messageTray.js

index 8a5c262a99406b1450589a86316524e2013eb2be..8e403f308e4a2f03a31d4b071bb1d8fb8941cab7 100644 (file)
@@ -1204,7 +1204,8 @@ var MessageTray = GObject.registerClass({
                 if (showNextNotification)
                     this._showNotification();
             }
-        } else if (this._notificationState == State.SHOWN) {
+        } else if (this._notificationState === State.SHOWING ||
+                   this._notificationState === State.SHOWN) {
             let expired = (this._userActiveWhileNotificationShown &&
                            this._notificationTimeoutId == 0 &&
                            this._notification.urgency != Urgency.CRITICAL &&
@@ -1215,10 +1216,12 @@ var MessageTray = GObject.registerClass({
             if (mustClose) {
                 let animate = hasNotifications && !this._notificationRemoved;
                 this._hideNotification(animate);
-            } else if (this._pointerInNotification && !this._banner.expanded) {
-                this._expandBanner(false);
-            } else if (this._pointerInNotification) {
-                this._ensureBannerFocused();
+            } else if (this._notificationState === State.SHOWN &&
+                       this._pointerInNotification) {
+                if (!this._banner.expanded)
+                    this._expandBanner(false);
+                else
+                    this._ensureBannerFocused();
             }
         }